const { Sequelize } = require('sequelize')
const sequelize = new Sequelize('express_admin', 'root', 'zkx116335', {
  host: 'localhost', // 数据库主机地址
  dialect: 'mysql', // 数据库类型
  logging: false, // 关闭日志输出
});
// 测试连接
(async function () {
  try {
    await sequelize.authenticate();
    console.log('Connection has been established successfully.');

    // 测试查询，例如查询数据库版本
    const result = await sequelize.query('SELECT VERSION()');
    console.log('Database version:', result[0][0]['VERSION()']);
  } catch (error) {
    console.error('Unable to connect to the database:', error);
  }
})();


// 导出连接
module.exports = sequelize